import type {
  ParseNovelRequest,
  ConfirmImportRequest,
  NovelCrawlData,
  NovelCrawlDataWithTempId,
  TempNovelData,
  ImportResult,
  ApiResponse,
} from './types/import'
import { http } from '@/http/http'

// ==================== 小说导入 ====================

// 重新导出类型
export type {
  ParseNovelRequest,
  ConfirmImportRequest,
  NovelCrawlData,
  NovelCrawlDataWithTempId,
  TempNovelData,
  ImportResult,
  ApiResponse,
} from './types/import'

/**
 * 解析小说链接
 */
export function parseNovelUrl(data: ParseNovelRequest) {
  return http.post<ApiResponse<NovelCrawlDataWithTempId>>('/import/parse', data)
}

/**
 * 确认导入小说
 */
export function confirmImport(data: ConfirmImportRequest) {
  return http.post<ApiResponse<ImportResult>>('/import/confirm', data)
}

/**
 * 获取临时小说数据
 */
export function getTempNovelData(tempId: string) {
  return http.get<ApiResponse<TempNovelData>>(`/import/temp/${tempId}`)
}

/**
 * 检查链接是否支持导入
 */
export function checkImportSupport(url: string) {
  return http.post<ApiResponse<{ supported: boolean; platform?: string }>>('/import/check', { url })
}